package com.project.restaurant.user.vo;

import com.project.restaurant.user.dto.UserAvatar;
import com.project.restaurant.user.enums.Sex;
import com.project.restaurant.pojo.User;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class UserPublicInfoVo extends UserAvatar {

    @ApiModelProperty(value = "性别")
    private Sex sex;

    @ApiModelProperty(value = "个性签名")
    private String individualitySignature;

    @ApiModelProperty(value = "邮箱")
    private String userEmail;

    @ApiModelProperty(value = "手机号")
    private String userPhone;

    public static UserPublicInfoVo getUserSafeInfoVo(User user){
        if(user==null){
            return null;
        }
        UserPublicInfoVo userSafeInfoVo = new UserPublicInfoVo();
        userSafeInfoVo.setIndividualitySignature(user.getIndividualitySignature())
                .setSex(Sex.getSex(user.isSex()))
                .setUserEmail(user.getUserEmail())
                .setUserPhone(user.getUserPhone())
                .setUserId(user.getUserId())
                .setUserAvatar(user.getUserAvatar())
                .setUserName(user.getUserName());
        return userSafeInfoVo;
    }

    @Override
    public String toString() {
        return "UserSafeInfoVo{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", userAvatar='" + userAvatar + '\'' +
                ", sex=" + sex +
                ", individualitySignature='" + individualitySignature + '\'' +
                ", userEmail='" + userEmail + '\'' +
                ", userPhone='" + userPhone + '\'' +
                '}';
    }
}
